package cn.edu.buaa.sei.jdat.search.trie;

import java.util.HashMap;

public class WordNode<T> {
	/**
	 * Data with non-null value means this node is an end node.
	 */
	protected T data;
	// for debug
	protected char character;
	protected HashMap<Character, WordNode<T>> children;

	protected WordNode() {
		data = null;
		children = null;
	}
	
	protected void addChild(char ch, WordNode<T> node) {
		if (children == null)
			children = new HashMap<Character, WordNode<T>>();
		children.put(ch, node);
		// for debug
		node.character = ch;
	}
	
	protected void removeChild(char ch) {
		children.remove(ch);
	}
	
	public T getData() {
		return data;
	}
	
	public char debug_name() {
		return character;
	}
}
